package cn.tedu.system.oa.notice.dao.repository;

import cn.tedu.system.oa.notice.pojo.entity.Notice;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Slf4j
public class NoticeCacheRepository {
    
    @Autowired
    private RedisTemplate<String, List<Notice>> redisTemplate;
    
    public List<Notice> getAllNotice(){
        ValueOperations<String,List<Notice>> stringOperations = redisTemplate.opsForValue();
        String noticeKey = "NOTICE_KEY";
        return stringOperations.get(noticeKey);
    }


    public void saveAllNotice(List<Notice> list) {
        String noticeKey = "NOTICE_KEY";
        redisTemplate.opsForValue().set(noticeKey,list);
    }
    
    
}
